package com.example.strategy.strategy.factory;


import com.example.strategy.strategy.service.Strategy;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class StrategyFactory {

    private static Map<Integer, Strategy> map=new HashMap();
    public static void register(Integer type,Strategy strategy){
        map.put(type,strategy);
    }

    public Strategy creator(Integer type){
        if (type==null){
            return null;
        }
        return map.get(type);
    }

}
